<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript">
    function  register() {
        let username =document.getElementById("username").value;
        let password =document.getElementById("password").value;
        //json data
        let  jsonData = {"username":username,"password":password};
        //convert to json obj
        let  jsonObj = JSON.stringify(jsonData);

        $.ajax({
            type: 'post',
            contentType:'application/json;charset=utf-8',
            data:jsonData,
            url: '$pageContext.request.contextPath}/stu/insert.do',
            success :respData=> {
                alert(respData.username +":"+ respData.password)
            }
        })
    }
</script>
<html>
<head>
    <title>用户注册</title>
</head>
<body>
用户名：<input type="text" name="username" id="username">
用户名：<input type="text" name="password" id="password">
<input type="button" value="注册" onclick="register()">
</body>
</html>
